<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        ul {
            list-style: none;
        }
        
        .box {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
            /*height: 2000px;*/
            /*overflow: hidden;*/
            /*background-color: red;*/
            position: relative;
            margin: 0 auto;
        }
        
        ul {
            width: 200px;
             position: absolute;
            top: 0;
            left: 0; 
            animation: bbb 2s linear;
            animation-fill-mode: forwards;
        }
        
        ul.aaaa {
            /*   animation: aaa 2s linear;
                       animation-fill-mode:forwards; */
        }
        
        .a {
            width: 100px;
            height: 100px;
            float: left;
            background-color: red;
        }
        
        .active {}
        
        @keyframes aaa {
            from {
                left: 0;
            }
            to {
                left: -100px;
            }
        }
        
        @keyframes bbb {
            from {
                left: -100px;
            }
            to {
                left: 0px;
            }
        }
        
        .b {
            width: 100px;
            height: 100px;
            float: left;
            background-color: pink;
        }
    </style>
    <title>Document</title>
</head>

<body>
    <div class="box">
        <ul>
            <li class="a"></li>
            <li class="b"></li>
        </ul>
    </div>
    <div id="content_list"></div>

    <script src="./js/jquery.min.js"></script>
    <script>
        //获取滚动条当前的位置 
        function getScrollTop() {
            var scrollTop = 0;
            if (document.documentElement && document.documentElement.scrollTop) {
                scrollTop = document.documentElement.scrollTop;
            } else if (document.body) {
                scrollTop = document.body.scrollTop;
            }
            return scrollTop;
        }

        //获取当前可是范围的高度 
        function getClientHeight() {
            var clientHeight = 0;
            if (document.body.clientHeight && document.documentElement.clientHeight) {
                clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
            } else {
                clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
            }
            return clientHeight;
        }

        //获取文档完整的高度 
        function getScrollHeight() {
            return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
        }

        //获得滚动数据的位置
        function setScrollPosition() {
            return (getScrollHeight() - getScrollTop() - getClientHeight());
        }
        var islock = false;
        $(function() {

            function getViewList() {
                $.ajax({
                    type: "GET",
                    url: "./js/img.json",
                    data: {},
                    dataType: "json",
                    cache: false,
                    success: function(result) {


                       var data=result.message;
                       console.log(data);
                       var html='';
                        $.each(data, function(k, v) {
                            html+='<li><img src="'+v.usrc+'" alt=""></li>'
                            }
                        );
                        console.log(html);
                        if (data.length > 0) {
                            $("#content_list").append(html);
                        }
                        islock = true;

                    },
                    beforeSend: function(XMLHttpRequest) {
                        console.log(XMLHttpRequest)
                        islock = false;
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        console.log(XMLHttpRequest)
                    }
                });
            };

            getViewList();
            $(window).scroll(function() {
                if (setScrollPosition() < 15 && islock) {
                    getViewList();
                };
            })

        });
    </script>
</body>

</html>